
import getApiData from "@/services/cpasRequest";

// 批量滚调
export async function rollBills(params: {
    dbname: string;
    billIDs: any;
    trueName: string | undefined;
    userCode: string
}) {
    try {
        const res = await getApiData("account.ZBAdjust.rollBill", params);
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    } catch (error) {
        return Promise.resolve({
            data: '滚调失败,请求失败！',
            success: false,
        });
    }
}


// 批量滚调
export async function rollReCal(params: {
    dbname: string;
    Data_ID: any;
    editUser: string | undefined;
    isRecalTZ: boolean

    // dbname: "undefined-C00017",
    // Data_ID: "2019",
    // editUser: "测试02",
    // isRecalTZ: true
}) {
    try {
        const res = await getApiData("account.reportItem.reCal", params);
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    } catch (error) {
        return Promise.resolve({
            data: '滚调重算失败,请求失败！',
            success: false,
        });
    }
}


// 获取已滚调单据列表
export async function getRollBillList(params: {
    dbname: string;
    billIDs: string;
}) {
    try {
        const res = await getApiData("account.adjustingEntry.getRollBillList", params);
        if (res.ok) {
            return Promise.resolve({
                data: res.data,
                success: true,
            });
        }
        return Promise.resolve({
            data: res.data,
            success: false,
        });
    } catch (error) {
        return Promise.resolve({
            data: '获取已滚调单据列表,请求失败！',
            success: false,
        });
    }
}